<?php

use yii\helpers\Html;
use yii\grid\GridView;
use backend\models\Goods;
use backend\models\User;
use backend\components\GoPager;
/* @var $this yii\web\View */
/* @var $searchModel backend\controllers\LogsSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */

$this->title = '日志管理';
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="logs-index">

    <h1><?= Html::encode($this->title) ?></h1>
    <?php  echo $this->render('_search', ['model' => $searchModel,'logssearch'=>$logssearch,'oprs'=>$oprs]); ?>


    <?= GridView::widget([
        'dataProvider' => $dataProvider,
        //'filterModel' => $searchModel,
        'columns' => [
            ['class' => 'yii\grid\SerialColumn'],



            ['attribute'=>'goodsid','label'=>'货品编号','format'=>'raw','value'=>function($model){
                $goods = Goods::findOne($model->goodsid);
                if(!empty($goods)){
                    return   "<div  >".Html::a($goods->goodsno,'/goods/view?id='.$goods->id,['style'=>'width:100px;word-break:break-word;white-space:pre-line;display:block'])."</div>";
                }else{
                    return "~";
                }

            }],
            ['attribute'=>'goodsid','label'=>'品名','format'=>'raw','value'=>function($model){
                $goods = Goods::findOne($model->goodsid);
                if(!empty($goods)){
                    return "<div style=\"width:100px;white-space:normal;word-break:break-all;\">".$goods->goodsname."</div>";
                }else{
                    return "~";
                }

            }],
            ['label'=>'操作人','attribute'=>'opid','value'=>function($model){
                $user = User::findOne($model->opid);
                $username = $user->realname ? $user->realname : $user->username;
                return $username ;
            }],

            'oprtype',
            ['attribute'=>'price_remark','format'=>'raw'],
            ['attribute'=>'remark','format'=>'raw','value'=>function($model){
                return "<div style=\"width:100px;white-space:normal;word-break:break-all;text-overflow: ellipsis;\">".$model->remark."</div>";
            }],
           // 'remark',
            'oprtime',

        ],
        'pager' =>[
            'class' => GoPager::className(),
            'firstPageLabel' => '首页',
            'prevPageLabel' => '<',
            'nextPageLabel' => '>',
            'lastPageLabel' => '尾页',
            'goPageLabel' => true,
            'totalPageLable' => '共x页',
            'goButtonLable' => 'GO',
            'maxButtonCount' => 5
        ]
    ]); ?>
</div>
